#pragma once

#include <QtCore/QDir>
#include <QtXml/QDomElement>

#include <engine.core/math.hpp>
#include <engine.core/Quad.hpp>

#include "exports.hpp"




/**
* A glyph contains the texture coordinates for a specific portion
* of the source UI texture. You can create a quad at (0,0) by calling
* Glyph::quad() and then moving it to the designated position.
*/
class ENGINE_UI_API Glyph
{
protected:

	QString    m_name;
	int2       m_pos;
	intsize2   m_size;

public:

	Glyph();
	Glyph(int2 pos, intsize2 size);
	Glyph(QDomElement glyph, QDir path);
	virtual ~Glyph();

	QString name() const;
	math::rectangle<int> rect() const;
	int2 pos() const;
	intsize2 size() const;

	virtual void setPos(int2 pos);
	void move(int2 delta);

	/**
	* Creates a quad at (0,0) that spans over it's given size and contains the given texture coordinates.
	* The quad can now be resized/moved to it's destination.
	*/
	virtual Quad quad() const;

	virtual QDomElement domElement(QDomDocument& document) const;
	virtual void setAttributes(QDomElement& element) const;
};
///////////////////////////////////////////////////////////////////////////////////////////////////
